<template>
	<div id="app">
		<router-view />
	</div>
</template>

<script>
	export default {
		name: 'App',
		data() {
			return {

			}
		},
		mounted() {
			this.gainMessage();
		},
		methods: {
			gainMessage() {
				let datas = {
					instanceId: this.getQueryString('instanceId'),
					timestamp: this.getQueryString('timestamp'),
					sign: this.getQueryString('sign'),
					number: this.getQueryString('number'),
					userType: this.getQueryString('userType')
				}
				let flag = true;
				for (let i in datas) {
					if (!datas[i] || datas[i] == "" || datas[i] == undefined) {
						flag = false;
					}
				}
				if (flag) {
					//查看是否合法
// 					this.$ajax.post(this, this.$api.GET_RETURN_PARAMS, datas,
// 						(res) => {});
					//判断小额还是进件
					let formdatas = {};
					formdatas.instanceId = datas.instanceId;
					formdatas.number = datas.number;
					this.$ajax.post(this, this.$api.GET_STATUS_GET, formdatas,
						(res) => {
							if (res.code == 200) {
								if (!res.data.content.code) {
									this.$router.push({
										name: "Error",
										query: {
											formdatas:JSON.stringify(formdatas)
										}
									})
								} else {
									if(this.getQueryString('userType')!='userclient'){
										this.$router.push({
											name: "LandlordCertification",
											query: {
												instanceId: datas.instanceId,
												number: datas.number
											}
										})
									}else{
										this.$router.push({
											name: "TenantCertification",
											query: {
												instanceId: datas.instanceId,
												number: datas.number
											}
										})
									}
								}
							} else {
								this.$router.push({
									name: "Error"
								})
							}

						});
				} else {
					this.$router.push({
						name: "Error"
					})
				}

			},
			getQueryString(name) {
				var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
				var reg_rewrite = new RegExp("(^|/)" + name + "/([^/]*)(/|$)", "i");
				var r = window.location.search.substr(1).match(reg);
				var q = window.location.pathname.substr(1).match(reg_rewrite);
				if (r != null) {
					return unescape(r[2]);
				} else if (q != null) {
					return unescape(q[2]);
				} else {
					return null;
				}
			}
		}
	}
</script>

<style>
	#app {
		font-family: 'Avenir', Helvetica, Arial, sans-serif;
		-webkit-font-smoothing: antialiased;
		-moz-osx-font-smoothing: grayscale;
		color: #2c3e50;
		/* background: #f0f2f5; */
		height: 100%;
	}
</style>
